package org.dubnation.base.listener;

import org.dubnation.auth.service.IPermissionScanService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * 定义监听器，监听程序启动
 * 监听器通过扫描注解分解注解将权限存入数据库，获取资源
 */

@WebListener  //将监听器交给Spring管理
public class PermissionListener implements ServletContextListener {

    @Autowired
    private IPermissionScanService scanService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("-------程序启动------");
        //扫描注解，获取权限，权限入库
        scanService.scan();
        System.out.println("-------程序结束------");
    }
}
